package com.enniswu.weitter.util;

import android.content.Context;
import android.content.res.Configuration;
import android.content.res.Resources;

import com.enniswu.weitter.data.local.SPSupport;
import com.enniswu.weitter.entity.RecreateEvent;

import org.greenrobot.eventbus.EventBus;

import java.util.Locale;

public class Utility {

    public static void setLanguage(Context context, String language) {
        Resources resources = context.getResources();
        Configuration configuration = resources.getConfiguration();
        configuration.locale = new Locale(language, "");
        resources.updateConfiguration(configuration, resources.getDisplayMetrics());
        SPSupport.getInstance().putLanguage(language);
        EventBus.getDefault().post(new RecreateEvent());
    }
}
